package objet;

import org.w3c.dom.Element;

import interfaces.XMLRMIField;
import interfaces.XMLRMIMethod;
import interfaces.XMLRMISerializable;
import tools.XMLTool;
import type.IMyDate;
import type.MyDate;

/**
 * Objet horloge sérialisable qui manipule le type dateTime
 * 
 * @author Kevin Pozderec,Faycal Abka
 *
 */
public class Horloge implements IHorloge,XMLRMISerializable{
	
	public int oid;
	public String type;
	
	@XMLRMIField(serializationName="d",serializationType="dateTime.iso8601")
	public IMyDate d;
	
	public Horloge(){
		this.oid = (int) (Math.random() * 1000);
		this.type = "IHorloge";
		d = new MyDate("2012","11","17","13","14","00");
	}

	@Override
	@XMLRMIMethod(language="Java",code="public String tellMeDate() {return d.getYear()+d.getMonth()+d.getDay()+\" T \"+d.getHour()+\" : \"+d.getMinute()+\" : \"+d.getSecond();}")
	public String tellMeDate() {
		return d.getYear()+d.getMonth()+d.getDay()+" T "+d.getHour()+" : "+d.getMinute()+" : "+d.getSecond();
	}

	@Override
	public String toXML() {
		return XMLTool.toXML(this, oid, type);
	}

	@Override
	public void updateFromXML(Element theXML) {
		System.out.println("Pas de mise à jour");
	}
	
	

}
